"use client";

import * as React from "react";
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
import { cn } from "../../utils";

const ToolbarRadioGroup = React.forwardRef<React.ElementRef<typeof RadioGroupPrimitive.Root>, React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>>(
	({ className, ...props }, ref) => {
		return <RadioGroupPrimitive.Root className={cn("flex items-center gap-1", className)} {...props} ref={ref} />;
	}
);
ToolbarRadioGroup.displayName = RadioGroupPrimitive.Root.displayName;

const ToolbarRadioGroupItem = React.forwardRef<React.ElementRef<typeof RadioGroupPrimitive.Item>, React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>>(
	({ className, children, ...props }, ref) => {
		return (
			<RadioGroupPrimitive.Item
				ref={ref}
				className={cn(
					"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
					"h-9 w-9 px-0 py-0",
					"bg-transparent hover:bg-muted hover:text-muted-foreground",
					"data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground",
					"[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
					className
				)}
				{...props}
			>
				{children}
			</RadioGroupPrimitive.Item>
		);
	}
);
ToolbarRadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;

export { ToolbarRadioGroup, ToolbarRadioGroupItem };
